<?xml version="1.0" encoding="UTF-8"?>

<!--
  Created by IntelliJ IDEA.
  User: azim
  Date: 5/19/13
  Time: 2:11 PM
-->

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
    <title>
        <ui:insert name="title">Podcstr Website</ui:insert>
    </title>
    <h:outputStylesheet library="css" name="styles.css"/>
    <h:outputScript library="js" name="scripts.js"/>
</h:head>

<h:body>

    <div id="container">

        <div id="head">

            <div style="float: left;">

                <h:form>

                    <p:themeSwitcher value="#{themeSwitcherBean.theme}"
                                     style="width:165px"
                                     id="defaultSwitcher">

                        <f:selectItem itemLabel="Choose Theme" itemValue=""/>
                        <f:selectItems value="#{themeSwitcherBean.themes}"/>
                        <p:ajax global="false" listener="#{themeSwitcherBean.saveTheme}"/>

                    </p:themeSwitcher>

                </h:form>
            </div>

            <div style="float: right; width: 20%">

                <h:form>

                    <p:remoteCommand name="search" action="#{podcastController.searchPodcast}"/>

                    <p:inputText name = "search"
                                 style="color: gray"
                                 onkeypress="if(event.keyCode == 13){search(); return false;}"
                                 onfocus="this.value=''"
                                 onblur="this.value='search'"
                                 value="#{podcastController.word}"/>
                    <br/>
                    <br/>
                    <c:choose>

                        <c:when test="#{userSession.user == null}">
                            <p:commandButton value="Login" action="#{indexController.viewLoginForm}"/>
                            &nbsp;&nbsp;&nbsp;
                            <p:commandButton value="Sign Up" action="#{indexController.createUserForm}"/>
                        </c:when>

                        <c:when test="#{userSession.user != null}">
                            <h:outputText value="welcome : "/>
                            <h:outputText style="color: blueviolet; font-weight: bold"
                                          value="#{userSession.user.username}"/>
                            &nbsp;&nbsp;&nbsp;
                            <p:commandButton value="Logout" action="#{loginController.logout}"/>
                        </c:when>

                    </c:choose>

                </h:form>

            </div>
            <br/>
            <ui:insert name="head">
                <span style="font: bold; font-size: x-large">Podcstr</span>
            </ui:insert>

        </div>

        <div id="navigation">

            <h:form>
                <c:choose>

                    <c:when test="#{userSession.user == null}">

                        <p:menubar>
                            <p:menuitem value="Home" url="index.xhtml" icon="ui-icon-home"/>
                            <p:menuitem value="Categories" url="show_podcast_categories.xhtml" icon="ui-icon-cart"/>
                        </p:menubar>

                    </c:when>

                    <c:when test="#{userSession.user != null}">

                        <p:menubar>
                            <p:menuitem value="Home" url="index.xhtml" icon="ui-icon-home"/>
                            <p:menuitem value="My Podcasts" url="login_show_my_podcasts.xhtml" icon="ui-icon-cart"/>
                            <p:menuitem value="Categories" url="show_podcast_categories.xhtml" icon="ui-icon-video"/>
                            <p:menuitem value="Account Settings" action="#{userController.showUserDetails(null)}"
                                        icon="ui-icon-person"/>
                        </p:menubar>

                    </c:when>

                </c:choose>

            </h:form>

        </div>

        <div id="body">

            <div>
                <h:graphicImage width="100%" height="200px" value="/resources/images/PodcastBanner.jpg"
                                alt="Podcstr Banner."/>
            </div>

            <div id="cbody">
                <br/>
                <ui:insert name="cbody"/>
            </div>

            <div id="left">
                <br/>

                <h2>Options : </h2>
                <br/>

                <h:form>

                    <p:tieredMenu style="width: 85%">

                        <ui:insert name="left"/>

                        <p:separator/>

                        <c:choose>

                            <c:when test="#{userSession.user == null}">

                                <p:menuitem value="Home" url="index.xhtml"/>
                                <p:menuitem value="Categories" url="show_podcast_categories.xhtml"/>

                            </c:when>

                            <c:when test="#{userSession.user != null}">

                                    <p:menuitem value="Home" url="index.xhtml"/>
                                    <p:menuitem value="My Podcasts" url="login_show_my_podcasts.xhtml"/>
                                    <p:menuitem value="Categories" url="show_podcast_categories.xhtml"/>
                                    <p:menuitem value="Account Settings" action="#{userController.showUserDetails(null)}"/>

                            </c:when>

                        </c:choose>

                    </p:tieredMenu>

                </h:form>


            </div>

        </div>

        <div class="space" style="visibility: hidden;"></div>

        <!--<div id="footer">
            <ui:insert name="footer">Designed by S M Raihan Azim</ui:insert>
        </div>-->
    </div>
</h:body>

</html>